<?php
/**
 * Sr Object Factory
 *   
 * @author wenqiang@6rooms.com
 * @version $Id: Factory.class.php,v 1.0 2013/12/3 14:22:48 gaowenqiang Exp $   
 * @package hw
 *
 */
class Sr_Factory extends Hw_Factory
{   
	/**
	 * 类前辍  Service, Model类名的前辍
	 *
	 */
	const CLASS_PREFIX_SERVICE = 'Sr_Service_';
	const CLASS_PREFIX_MODEL = 'Sr_Model_';
	
	/**
	 * 获取Service对象
	 *
	 * @param string $name 短类名
	 * @param mixed $args 参数
	 * @param string $prefix 类名前辍
	 * @param bool $cache 是否从缓存中获取
	 * @return object (Class Type: Sr_Service_Base)
	 *
	 */
	public static function service($name, $args = null, $prefix = null, $cache = false)
	{
		$prefix = self::CLASS_PREFIX_SERVICE . $prefix;
		$className = $prefix . $name;

		return self::object($className, $args, $cache);
	}
	
	/**
	 * 获取Model对象
	 *
	 * @param string $name 短类名
	 * @param mixed $args 参数
	 * @param string $prefix 类名前辍
	 * @param bool $cache 是否从缓存中获取
	 * @return object (Class Type: Sr_Model_Base)
	 *
	 */
	public static function model($name, $args = null, $prefix = null, $cache = false)
	{
		$prefix = self::CLASS_PREFIX_MODEL . $prefix;
		$className = $prefix . $name;

		return self::object($className, $args, $cache);
	}

	/**
	 * 获取数据库接口类
	 *
	 * @param mixed $args 初始参数
	 * @param bool $cache 是否从缓存中获取
	 * @return object (Class Type: DBHelperi_applepie)
	 *
	 */
	public static function getDbBySr($args = null, $cache = true)
	{
		$className = 'DBHelperi_applepie';
		return self::object($className, $args, $cache);
	}
	
	/**
	 * 获取分页类
	 *
	 * @param mixed $args 初始参数
	 * @param bool $cache 是否从缓存中获取
	 * @return object (Class Type: Pager)
	 *
	 */
	public static function getPager($args, $cache = true)
	{
		$className = 'Pager';
		return self::object($className, $args, $cache);	
	}

}
